package com.gitee.qdbp.general.trade.api.order.manage.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import com.gitee.qdbp.able.jdbc.paging.PartList;
import com.gitee.qdbp.base.annotation.DataIsolation;
import com.gitee.qdbp.base.annotation.OperateTraces;
import com.gitee.qdbp.base.enums.DataState;
import com.gitee.qdbp.general.trade.enums.FundReceiveType;
import com.gitee.qdbp.general.trade.enums.OrderType;
import com.gitee.qdbp.general.trade.enums.PayChannel;
import com.gitee.qdbp.general.trade.enums.PaySource;
import com.gitee.qdbp.general.trade.enums.PayState;

/**
 * 订单支付实体类
 *
 * @author zhh
 * @version 180625
 */
@OperateTraces(id = "id")
@DataIsolation("tenantCode")
public class OrderPaymentBean implements Serializable {

    /** 版本序列号 **/
    private static final long serialVersionUID = 1L;

    /** 表名 **/
    public static final String TABLE = "vml_order_payment";

    /** 主键 **/
    private String id;

    /** 收款类型(0.平台收款|1.商家收款|2.平台代商家收款) **/
    private FundReceiveType receiveType;

    /** 商家租户编号 **/
    private String tenantCode;

    /** 商家账户 **/
    private String merchantAccount;

    /** 订单ID **/
    private String orderId;

    /** 订单类型(0.捐款订单|1.商品订单) **/
    private OrderType orderType;

    /** 关联业务ID **/
    private String dataId;

    /** 用户ID **/
    private String userId;

    /** 订单内容 **/
    private String orderContent;

    /** 订单金额(人民币元) **/
    private Double orderAmount;

    /** 支付金额(人民币元) **/
    private Double payAmount;

    /** 支付渠道(0.线下|1.支付宝|2.微信|3.银联) **/
    private PayChannel payChannel;

    /** 支付来源(1.PC网页支付|2.H5网页支付|3.APP支付) **/
    private PaySource paySource;

    /** 支付时间 **/
    private Date payTime;

    /** 支付单据号 **/
    private String voucherCode;

    /** 交易流水号 **/
    private String transactCode;

    /** 支付状态(1.未支付|2.支付中|3.支付成功|4.支付失败) **/
    private PayState payState;

    /** 选项 **/
    private OrderPaymentOptions options;

    /** 创建时间 **/
    private Date createTime;

    /** 数据状态:0为正常|其他为删除 **/
    private DataState dataState;

    /** 获取主键 **/
    public String getId() {
        return id;
    }

    /** 设置主键 **/
    public void setId(String id) {
        this.id = id;
    }

    /** 获取收款类型(0.平台收款|1.商家收款|2.平台代商家收款) **/
    public FundReceiveType getReceiveType() {
        return receiveType;
    }

    /** 设置收款类型(0.平台收款|1.商家收款|2.平台代商家收款) **/
    public void setReceiveType(FundReceiveType receiveType) {
        this.receiveType = receiveType;
    }

    /** 获取商家租户编号 **/
    public String getTenantCode() {
        return tenantCode;
    }

    /** 设置商家租户编号 **/
    public void setTenantCode(String tenantCode) {
        this.tenantCode = tenantCode;
    }

    /** 获取商家账户 **/
    public String getMerchantAccount() {
        return merchantAccount;
    }

    /** 设置商家账户 **/
    public void setMerchantAccount(String merchantAccount) {
        this.merchantAccount = merchantAccount;
    }

    /** 获取订单ID **/
    public String getOrderId() {
        return orderId;
    }

    /** 设置订单ID **/
    public void setOrderId(String orderId) {
        this.orderId = orderId;
    }

    /** 获取订单类型(0.捐款订单|1.商品订单) **/
    public OrderType getOrderType() {
        return orderType;
    }

    /** 设置订单类型(0.捐款订单|1.商品订单) **/
    public void setOrderType(OrderType orderType) {
        this.orderType = orderType;
    }

    /** 获取关联业务ID **/
    public String getDataId() {
        return dataId;
    }

    /** 设置关联业务ID **/
    public void setDataId(String dataId) {
        this.dataId = dataId;
    }

    /** 获取用户ID **/
    public String getUserId() {
        return userId;
    }

    /** 设置用户ID **/
    public void setUserId(String userId) {
        this.userId = userId;
    }

    /** 获取订单内容 **/
    public String getOrderContent() {
        return orderContent;
    }

    /** 设置订单内容 **/
    public void setOrderContent(String orderContent) {
        this.orderContent = orderContent;
    }

    /** 获取订单金额(人民币元) **/
    public Double getOrderAmount() {
        return orderAmount;
    }

    /** 设置订单金额(人民币元) **/
    public void setOrderAmount(Double orderAmount) {
        this.orderAmount = orderAmount;
    }

    /** 获取支付金额(人民币元) **/
    public Double getPayAmount() {
        return payAmount;
    }

    /** 设置支付金额(人民币元) **/
    public void setPayAmount(Double payAmount) {
        this.payAmount = payAmount;
    }

    /** 获取支付渠道(0.线下|1.支付宝|2.微信|3.银联) **/
    public PayChannel getPayChannel() {
        return payChannel;
    }

    /** 设置支付渠道(0.线下|1.支付宝|2.微信|3.银联) **/
    public void setPayChannel(PayChannel payChannel) {
        this.payChannel = payChannel;
    }

    /** 获取支付来源(1.PC网页支付|2.H5网页支付|3.APP支付) **/
    public PaySource getPaySource() {
        return paySource;
    }

    /** 设置支付来源(1.PC网页支付|2.H5网页支付|3.APP支付) **/
    public void setPaySource(PaySource paySource) {
        this.paySource = paySource;
    }

    /** 获取支付时间 **/
    public Date getPayTime() {
        return payTime;
    }

    /** 设置支付时间 **/
    public void setPayTime(Date payTime) {
        this.payTime = payTime;
    }

    /** 获取支付单据号 **/
    public String getVoucherCode() {
        return voucherCode;
    }

    /** 设置支付单据号 **/
    public void setVoucherCode(String voucherCode) {
        this.voucherCode = voucherCode;
    }

    /** 获取交易流水号 **/
    public String getTransactCode() {
        return transactCode;
    }

    /** 设置交易流水号 **/
    public void setTransactCode(String transactCode) {
        this.transactCode = transactCode;
    }

    /** 获取支付状态(1.未支付|2.支付中|3.支付成功|4.支付失败) **/
    public PayState getPayState() {
        return payState;
    }

    /** 设置支付状态(1.未支付|2.支付中|3.支付成功|4.支付失败) **/
    public void setPayState(PayState payState) {
        this.payState = payState;
    }

    /** 获取选项 **/
    public OrderPaymentOptions getOptions() {
        return options;
    }

    /** 获取选项, force=是否强制返回非空对象 **/
    public OrderPaymentOptions getOptions(boolean force) {
        if (options == null && force) {
            options = new OrderPaymentOptions();
        }
        return options;
    }

    /** 设置选项 **/
    public void setOptions(OrderPaymentOptions options) {
        this.options = options;
    }

    /** 获取创建时间 **/
    public Date getCreateTime() {
        return createTime;
    }

    /** 设置创建时间 **/
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    /** 获取数据状态:0为正常|其他为删除 **/
    public DataState getDataState() {
        return dataState;
    }

    /** 设置数据状态:0为正常|其他为删除 **/
    public void setDataState(DataState dataState) {
        this.dataState = dataState;
    }

    /**
     * 将当前对象转换为子类对象
     *
     * @param clazz 目标类型
     * @return 目标对象
     */
    public <T extends OrderPaymentBean> T to(Class<T> clazz) {
        T instance;
        try {
            instance = clazz.newInstance();
        } catch (Exception e) {
            throw new IllegalArgumentException("Failed to create " + clazz.getSimpleName() + " instance.", e);
        }

        instance.setId(this.getId()); // 主键
        instance.setReceiveType(this.getReceiveType()); // 收款类型(0.平台收款|1.商家收款|2.平台代商家收款)
        instance.setTenantCode(this.getTenantCode()); // 商家租户编号
        instance.setMerchantAccount(this.getMerchantAccount()); // 商家账户
        instance.setOrderId(this.getOrderId()); // 订单ID
        instance.setOrderType(this.getOrderType()); // 订单类型(0.捐款订单|1.商品订单)
        instance.setDataId(this.getDataId()); // 关联业务ID
        instance.setUserId(this.getUserId()); // 用户ID
        instance.setOrderContent(this.getOrderContent()); // 订单内容
        instance.setOrderAmount(this.getOrderAmount()); // 订单金额(人民币元)
        instance.setPayAmount(this.getPayAmount()); // 支付金额(人民币元)
        instance.setPayChannel(this.getPayChannel()); // 支付渠道(0.线下|1.支付宝|2.微信|3.银联)
        instance.setPaySource(this.getPaySource()); // 支付来源(1.PC网页支付|2.H5网页支付|3.APP支付)
        instance.setPayTime(this.getPayTime()); // 支付时间
        instance.setVoucherCode(this.getVoucherCode()); // 支付单据号
        instance.setTransactCode(this.getTransactCode()); // 交易流水号
        instance.setPayState(this.getPayState()); // 支付状态(1.未支付|2.支付中|3.支付成功|4.支付失败)
        instance.setOptions(this.getOptions()); // 选项
        instance.setCreateTime(this.getCreateTime()); // 创建时间
        instance.setDataState(this.getDataState()); // 数据状态:0为正常|其他为删除
        return instance;
    }

    /**
     * 将OrderPaymentBean转换为子类对象
     *
     * @param beans 待转换的对象列表
     * @param clazz 目标类型
     * @param <T> OrderPaymentBean或子类
     * @param <C> T的子类
     * @return 目标对象列表
     */
    public static <T extends OrderPaymentBean, C extends T> List<C> to(List<T> beans, Class<C> clazz) {
        if (beans == null) {
            return null;
        }
        List<C> list;
        if (beans instanceof PartList) {
            PartList<C> partlist = new PartList<>();
            partlist.setTotal(((PartList<?>) beans).getTotal());
            list = partlist;
        } else {
            list = new ArrayList<>();
        }
        for (OrderPaymentBean bean : beans) {
            list.add(bean.to(clazz));
        }
        return list;
    }

}